cross Function

public function cross(a, b) result(result)

function that calculates the cross product between two real 3-dimensional vectors and 1


  1. the wedge notation can sometimes be used to denote the vector product. 

Arguments

Type IntentOptional Attributes Name
real(kind=dp), DIMENSION(3) :: a
real(kind=dp), DIMENSION(3) :: b

Return Value real(kind=dp), DIMENSION(3)


Source Code

    FUNCTION cross(a,b) RESULT(result)

        REAL(dp), DIMENSION(3) :: a, b
        REAL(dp), DIMENSION(3) :: result

        result(1) = a(2) * b(3) - b(2) * a(3)
        result(2) = - (a(1) * b(3) - b(1) * a(3))
        result(3) = a(1) * b(2) - b(1) * a(2)

    END FUNCTION cross